function test7( )
%TEST4 Summary of this function goes here
%   Detailed explanation goes here
    
    
    W = imread('../TestImg/m.jpg');
    W = double(W(:,:,1));
%     S = [2,4;6,8];
    S = fspecial('motion',20,45);

     H = conv2(W,S)./sum(S(:));
     H2 = NewFullSize(H, size(S,1), size(S,2));
%    H = imfilter(W,S,'replicate')./sum(S(:));
    
    size(W)
    size(S)
    size(H)
    size(H2)
    
    t = cputime;
    WRec = MyDeconv2DFast(H,S,size(W,1),size(W,2),20,0);
    disp(cputime-t);
    
    
    figure(1); 
    subplot(2,2,1);
    imshow(ZeroToOne(W));
    disp('W');
    %disp(W);
    
    subplot(2,2,2);
    imshow(ZeroToOne(S));
    disp('S');
    %disp(S);
    
    subplot(2,2,3);
    imshow(ZeroToOne(H));
    disp('H');
%     disp(H);
    
    subplot(2,2,4);
    imshow(ZeroToOne(WRec));
    disp('WRec');
%     disp(WRec);
    
end

function y = ZeroToOne(x)
    
    y = x-min(x(:));
    y = y./max(y(:));

end

function y = NewFullSize(H, m, n)
    [mh,nh] = size(H);
    for i = m:(mh-m)
        H(i, 1:n) = H(i,n);
        H(i, (nh-n):nh) = H(i, (nh-n));
    end
    
    for j = 1:nh
        H(1:m, j) = H(m,j);
        H((mh-m):mh, j) = H((mh-m),j);
    end
    
    y = H;
end

